package com.xbxkj.api.app.mini.controller;

import com.xbxkj.commen.controller.helper.$;
import com.xbxkj.commen.controller.model.ApiResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author 张子艺
 * @packge com.xbxkj.api.app.mini.controller
 * @data 2020-01-02 15:28
 * @project HuaZhouDelivery
 */
@Controller
@RequestMapping("/app/mini/{appid}/commen")
@Slf4j
@Api( tags="公用接口")
public class CommenController extends  MiniAppBaseController{
    /** 添加UserAddress
     * @return 返回统一信息
     */
    @ApiOperation(value = "获取city城市信息", notes = "获取city城市信息")
    @GetMapping(value = "/city.json")
    @ApiImplicitParam(name = "token", value = "令牌" , paramType = "header", required = true)
    public String city(HttpServletRequest request   ){
        return "/static/city.json";
    }


    /** 上传图片
     * @return 返回统一信息
     */
    @ApiOperation(value = "上传图片", notes = "上传图片")
    @PostMapping(value = "/upload")
    @ApiImplicitParam(name = "token", value = "令牌" , paramType = "header", required = true)
    @ResponseBody
    public ApiResultModel<Object> upload(MultipartFile file) throws IOException {
        Object url=ossService.upload(file);

        return $.success(url);
    }



}
